package Lambda;

import java.util.function.*;

/**
 * @projectName: Webflux_demo
 * @package: Lambda
 * @className: JdkFunctionDmo
 * @author: 冷环渊 doomwatcher
 * @description: TODO
 * @date: 2021/12/13 19:04
 * @version: 1.0
 */
public class JdkFunctionDmo {
    public static void main(String[] args) {
        // Supplier 没有输入 只有输出
        Supplier<String> supplier = () -> "我是一个  Supplier 方法";
        System.out.println(supplier.get());

        //Consummer 只有输入 没有输出
        Consumer<String> con = i -> System.out.println("我是一个 Conusmer Demo" + i);
        con.accept(" hello Consumer i am 冷环渊");

        //function 放入一个对象生成一个新的对象
        Function<Integer, Integer> func = i -> i * i;
        Integer apply = func.apply(9);
        System.out.println("Function demo out:" + apply);

        //对于 放入和输出类型一致的哦我们 Function接口里有一个实现 UnaryOperator
        UnaryOperator<Integer> unaryOperator = i -> i * i - i;
        System.out.println("Function demo out:" + unaryOperator.apply(9));

        //输入两个对象 返回一个新的对象 BiFunction
        BiFunction<Integer, Integer, String> biFunction = (i, e) -> i * e + "元";
        System.out.println("我一共该交给你多少钱：" + biFunction.apply(40, 80));
    }
}
